function add0(m){return m<10?'0'+m:m }
function format(shijianchuo)
{
//shijianchuo是整数，否则要parseInt转换
var time = new Date(shijianchuo);
var y = time.getFullYear();
var m = time.getMonth()+1;
var d = time.getDate();
var h = time.getHours();
var mm = time.getMinutes();
var s = time.getSeconds();
return y+'-'+add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(mm)+':'+add0(s);
}
$(document).ready(function(){
	var rootPath = getRootPath();
	var carOwnerUserId = 84;
	
	$.ajax({
		method : 'get',
		url : rootPath+'/wechat/api/maintain/rescues?carOwnerUserId='+carOwnerUserId,
		error:function(XMLHttpRequest, ajaxOptions, thrownError){
			alert("连接服务器错误!");
		},
		success : function(resultData){
			
			var wholeHtml = '';
			
			$.each(resultData,function(sosHelpIndex,sosHelpObj){
				
				var sosHelpHtml = '';
				
				var status = '';
				
				if(sosHelpObj.status==11001101)
					status = '待救援';
				else if(sosHelpObj.status==11001102)
					status = '救援中';
				else 
					status = '救援完成';
				
				var soshelpId = sosHelpObj.soshelpId
				
				sosHelpHtml = sosHelpHtml 	+ '<div class="panel panel-default">'
											+ 	'<a href="soshelpinfor.html?soshelpId='+soshelpId+'" class="list-group-item clearfix">'
											+ 	  '<div style="width:70%;float:left">'
											+ 	    '<p>'
											+		  '救援位置：<span>'+ '上海市长宁区定西路' +'</span>'
											+ 		'</p>'
											+ 	  '</div>'
											+ 	  '<div style="width:20%;float:right">'
											+ 	    '<span class="glyphicon glyphicon-chevron-right"></span>'
											+ 	  '</div>'
											+ 	  '<div style="width:70%;float:left">'
			  								+		'<p>'
			  								+		  '请求时间：<span>'+ format(sosHelpObj.createDate) +'</span>'
			  								+		'</p>'
			  								+		'<p>'
			  								+		  '救援时间：<span>'+ sosHelpObj.supportDate +'</span>'
			  								+		'</p>'
			  								+	  '</div>'
											+ 	  '<div style="width:20%;float:right">'
											+	  '<p></p>'
											+	  '<p>'
											+	    '<span>'+ status + '</span>'
											+	  '</p>'
											+	 '</div>'
											+ 	'</a>'
											+ '</div>'
				
				wholeHtml += sosHelpHtml;
			});
			
			$("#all").append(wholeHtml);
		}
	});
})
